<%= render :partial => 'admin/shared/configuration_menu' %>

<h1><%= t('mail_server_preferences') %></h1>

<% form_tag(admin_mail_settings_path, :method => :put) do -%>

<div class="yui-g">

  <div class="yui-u first">

    <fieldset>
      <legend><%= t('general') %></legend>

      <p>
        <label>
	      <input name="preferences[enable_mail_delivery]" type="hidden" value="0" />
          <%= check_box_tag('preferences[enable_mail_delivery]', "1", Spree::Config[:enable_mail_delivery]) %>
          <%= t('enable_mail_delivery') %>
        </label>
      </p>

      <p>
        <label><%= t('send_mails_as') %></label><br />
        <%= text_field_tag('preferences[mails_from]', Spree::Config[:mails_from], :maxlength => 256)%>
        <br/>
        <span class="info">
          Send all mails as from the following address.
        </span>
      </p>

      <p>
        <label><%= t('send_copy_of_all_mails_to') %></label><br />
        <%= text_field_tag('preferences[mail_bcc]', Spree::Config[:mail_bcc], :size => 40, :maxlength => 256)%>
        <br/>
        <span class="info">
          Sends a copy of all outgoing mails to this address. For multiple addresses, separate with commas.
        </span>
      </p>

    </fieldset>



    <fieldset>
      <legend><%= t('orders') %></legend>
      <p>
        <label><%= t('send_order_mails_as') %></label><br />
        <%= text_field_tag('preferences[order_from]', Spree::Config[:order_from], :maxlength => 256)%>
        <br/>
        <span class="info">
          Send orders mails as from the following address.
        </span>
      </p>

      <p>
        <label><%= t('send_copy_of_orders_mails_to') %></label><br />
        <%= text_field_tag('preferences[order_bcc]', Spree::Config[:order_bcc], :size => 40, :maxlength => 256)%>
        <br/>
        <span class="info">
          Sends a copy of all order's mails to this address. For multiple addresses, separate with commas.
        </span>
      </p>
    </fieldset>


  </div>

  <div class="yui-u">

    <fieldset>
      <legend><%= t('smtp') %></legend>
      <p>
        <label><%= t("smtp_domain") %></label><br />
        <%= text_field_tag('preferences[mail_domain]', Spree::Config[:mail_domain]) %>
      </p>
      <p>
        <label><%= t('smtp_mail_host') %></label><br />
        <%= text_field_tag('preferences[mail_host]', Spree::Config[:mail_host])%>
      </p>
      <p>
        <label><%= t('smtp_port') %></label><br />
        <%= text_field_tag('preferences[mail_port]', Spree::Config[:mail_port])%>
      </p>
      <p>
        <label><%= t('secure_connection_type')  %></label><br />
        <%= select_tag('preferences[secure_connection_type]',
        options_for_select(
        AppConfiguration::SECURE_CONNECTION_TYPES, 
        Spree::Config[:secure_connection_type])) %>
      </p>
      <p>
        <label><%= t('smtp_authentication_type') %></label><br />
        <%= select_tag('preferences[mail_auth_type]',
        options_for_select(AppConfiguration::MAIL_AUTH, 
        Spree::Config[:mail_auth_type])) %>
      </p>

      <p>
        <label><%= t('smtp_username') %></label><br />
        <%= text_field_tag('preferences[smtp_username]', Spree::Config[:smtp_username])%>
      </p>
      <p>
        <label><%= t('smtp_password') %></label><br />
        <%= password_field_tag('preferences[smtp_password]', Spree::Config[:smtp_password])%>
      </p>
    </fieldset>

  </div>

</div>

<p class="form-buttons"><%= button t('save_preferences') %></p>

<% end -%>
